package com.tebiecloud.mpweixin.server.listener;

import com.alibaba.fastjson.JSONObject;
import com.tebiecloud.common.utils.JsonUtils;
import com.tebiecloud.mpweixin.client.constants.QueueConstants;
import com.tebiecloud.mpweixin.client.model.MpUserVisit;
import com.tebiecloud.mpweixin.client.model.entity.MpweixinUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.handler.annotation.Payload;

/**
 * 监听公众号粉丝访问事件
 * @Author: tebie
 * @Date: 2019-09-10 11:21
 */
@Slf4j
@Configuration
public class MpweixinUserVisitListener {

    /**
     * 接收粉丝访问公众号消息
     * @param mpUserVisit
     */
    @RabbitListener(queues = QueueConstants.QUEUE_MPWEIXIN_USER_VISIT)
    public void ScanApiResourceQueue(@Payload MpUserVisit mpUserVisit) {
        try {
            log.info("xiaoc>> 粉丝访问公众号了，但未处理，mpUserVisit: {}", JsonUtils.Obj2Str(mpUserVisit));
        } catch (Exception e) {
            log.error("error:", e);
        }
    }

}
